import { useRouterStoreHook } from "@/store/modules/router";
import {
  deviceModuleOptions,
  specialGasOptions,
  atmosphereOptions,
  chemicalsOptions,
  waterOptions,
  machineOptions1,
  machineOptions2,
  electricityOptions
} from "@/utils/constant";

const routerStore = useRouterStoreHook();

const getGasDeviceUsedTypeByGasType = (index: number) => {
  let label = "";
  let placeholder = "";
  let option = [];
  switch (routerStore.activeViceMenu) {
    case "SPECIALTY":
      label = "用气类型";
      placeholder = `请选择${label}`;
      option = specialGasOptions;
      break;
    case "ATMOSPHERIC":
      label = "用气类型";
      placeholder = `请选择${label}`;
      option = atmosphereOptions;
      break;
    case "CHEMICALS":
      label = index === 1 ? "化学品类型" : "用气类型";
      placeholder = `请选择${label}`;
      option = chemicalsOptions;
      break;
  }
  return { label, placeholder, option };
};

const getGasDeviceUsedTypeByClass = (index: number) => {
  let label = "";
  let placeholder = "";
  let option = [];
  let dayDeviceUsedLabel = "日均流量";
  let monthDeviceUsedLabel = "月均流量";
  switch (routerStore.subject) {
    case "GAS":
      const { label: label_, placeholder: placeholder_, option: option_ } = getGasDeviceUsedTypeByGasType(index);
      label = label_;
      placeholder = placeholder_;
      option = option_;
      break;
    case "WATER":
      label = "用水类型";
      placeholder = `请选择${label}`;
      option = waterOptions;
      break;
    case "MACHINE":
      label = index === 1 ? "用水类型" : "用气类型";
      placeholder = `请选择${label}`;
      option = index === 1 ? machineOptions1 : machineOptions2;
      break;
    case "ELECTRICTITY":
      label = "用电类型";
      placeholder = `请选择${label}`;
      option = electricityOptions;
      dayDeviceUsedLabel = "日均电量";
      monthDeviceUsedLabel = "月均电量";
      break;
  }
  return {
    label,
    placeholder,
    option,
    dayDeviceUsedLabel,
    monthDeviceUsedLabel
  };
};

/**
 * @description: 获取search配置信息
 * @param {number} index
 * @return {Array<CommonSearch.SearchOption>}
 */
export const useSearchOption = (index?: number): Array<CommonSearch.SearchOption> => {
  const deviceModule: CommonSearch.SearchOption = {
    label: "Module",
    key: "deviceModule",
    value: "",
    type: "select",
    placeholder: "请选择Module",
    option: deviceModuleOptions
  };
  console.log(index);
  //  暂时先隐藏 2024-8-28
  // const deviceType: CommonSearch.SearchOption = {
  //   label: "机台类型",
  //   key: "deviceType",
  //   value: null,
  //   type: "select",
  //   placeholder: "请选择机台类型",
  //   option: [
  //     {
  //       label: "PROCESS_PH",
  //       value: "PROCESS_PH"
  //     },
  //     {
  //       label: "PROCESS_TF",
  //       value: "PROCESS_TF"
  //     },
  //     {
  //       label: "PROCESS_WET",
  //       value: "PROCESS_WET"
  //     },
  //     {
  //       label: "PROCESS_CMP",
  //       value: "PROCESS_CMP"
  //     },
  //     {
  //       label: "PROCESS_DF",
  //       value: "PROCESS_DF"
  //     },
  //     {
  //       label: "PROCESS_ETOH",
  //       value: "PROCESS_ETOH"
  //     },
  //     {
  //       label: "METROLOGY_MET",
  //       value: "METROLOGY_MET"
  //     },
  //     {
  //       label: "METROLOGY_WAT",
  //       value: "METROLOGY_WAT"
  //     },
  //     {
  //       label: "METROLOGY_DFT",
  //       value: "METROLOGY_DFT"
  //     },
  //     {
  //       label: "TEST_CP",
  //       value: "TEST_CP"
  //     },
  //     {
  //       label: "TEST_FT",
  //       value: "TEST_FT"
  //     }
  //   ]
  // };

  // const { label, placeholder, option } = getGasDeviceUsedTypeByClass(index);
  // const deviceUsedType: CommonSearch.SearchOption = {
  //   label,
  //   placeholder,
  //   option,
  //   key: "deviceUsedType",
  //   value: "",
  //   type: "select"
  // };
  const commonQueryValue: CommonSearch.SearchOption = {
    label: "机台名称",
    key: "commonQueryValue",
    value: "",
    type: "input",
    placeholder: "请输入机台名称"
  };
  return [deviceModule, commonQueryValue];
};

/**
 * @description: 获取table表格的表头（cloumns）信息
 * @return {*}
 */
export const useTableCloumns = (index: number): Array<any> => {
  const { label, dayDeviceUsedLabel, monthDeviceUsedLabel } = getGasDeviceUsedTypeByClass(index);
  return [
    {
      label: "Module",
      prop: "deviceModule",
      width: 130,
      sortable: "custom"
    },
    {
      label: "机台类型",
      prop: "deviceType",
      width: 130,
      sortable: "custom"
    },
    {
      label: "机台名称",
      prop: "deviceId",
      width: 130,
      sortable: "custom"
    },
    {
      label,
      prop: "deviceUsedType",
      width: 130,
      sortable: "custom"
    },
    {
      label: dayDeviceUsedLabel,
      prop: "dayDeviceUsedNum",
      width: 130,
      sortable: "custom"
    },
    {
      label: "日累计量",
      prop: "dayDeviceUsedTotalNum",
      width: 130,
      sortable: "custom"
    },
    {
      label: monthDeviceUsedLabel,
      prop: "monthDeviceUsedNum",
      width: 130,
      sortable: "custom"
    },
    {
      label: "月累计量",
      prop: "monthDeviceUsedTotalNum",
      width: 130,
      sortable: "custom"
    }
  ];
};
